package com.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.service.EmpServiceImpl;
import com.vo.ResponseBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/api")
public class EmpController {

    @Autowired
    private EmpServiceImpl empService;

    @RequestMapping("/searchEmp")
    public ResponseBean searchEmp(@RequestParam(defaultValue = "1")int page,@RequestParam(defaultValue = "10")int limit,@RequestParam Map m){
        System.out.println(m);
        IPage result=empService.searchEmp(page,limit,m);

        return new ResponseBean(0,result.getTotal(),result.getRecords());

    }

    @RequestMapping("/updatesex")
    public ResponseBean updatesex(@RequestParam("empId")Integer empId,@RequestParam("sex")Integer sex){

        int i=empService.updatesex(empId,sex);
        ResponseBean bean=null;
        if (i>0){
            return bean=new ResponseBean(200,0,"操作成功");

        }else{
            return bean=new ResponseBean(500,0,"操作失败");
        }
    }


}
